home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / ply15dat.zip / DEF.H < prev    next >
C/C++ Source or Header  |  1992-10-03  |  2KB  |  67 lines

  1. /*
  2.  * def.h contains some useful definitions for "C" programs.
  3.  *
  4.  * Version:  2.2 (11/17/87)
  5.  * Author:  Eric Haines, 3D/Eye, Inc.
  6.  *
  7.  * Modified: 1 October 1992
  8.  *           Alexander R. Enzmann
  9.  */
  10.  
  11. #define EPSILON 5.0e-6
  12.  
  13. #ifndef FALSE
  14. #define FALSE 0
  15. #endif
  16.  
  17. #ifndef NULL
  18. #define NULL 0
  19. #endif
  20.  
  21. #ifndef TRUE
  22. #define TRUE 1
  23. #endif
  24.  
  25. #ifndef PI
  26. #define PI 3.141592653589793
  27. #endif
  28.  
  29. typedef double MATRIX[4][4] ;  /* row major form */
  30.  
  31. typedef struct {
  32.    double x, y, z, w;
  33.    } COORD4, *COORD4_P;
  34.  
  35. #define POW(A,B)     ( (A) == 0 ? 0 : ( (B) == 0 ? 1 : pow(A, B) ) )
  36. #define SGN(A)       ( (A) < 0 ? -1 : ( (A) > 0 ? 1 : 0) )
  37. #define ABS(A)       ( (A) < 0 ? -(A) : (A) )
  38. #define FRACTION(A)  ( (A) - (long)(A) )
  39. #define MAX(A,B)     ( (A) > (B) ? (A) : (B) )
  40. #define MAX3(A,B,C)  ( MAX( MAX( A,B ), C ) )
  41. #define MIN(A,B)     ( (A) < (B) ? (A) : (B) )
  42. #define MIN3(A,B,C)  ( MIN( MIN( A,B ), C ) )
  43. #define SQR(A)       ( (A) * (A) )
  44.  
  45. #define ADD2_COORD(r,a)   { (r).x += (a).x; (r).y += (a).y;\
  46.                             (r).z += (a).z; }
  47. #define ADD3_COORD(r,a,b) { (r).x = (a).x + (b).x;\
  48.                             (r).y = (a).y + (b).y;\
  49.                             (r).z = (a).z + (b).z; }
  50. #define COPY_COORD(r,a)   { (r).x = (a).x; (r).y = (a).y; (r).z = (a).z;}
  51. #define COPY_COORD4(r,a)  { (r).x = (a).x; (r).y = (a).y; (r).z = (a).z;\
  52.                             (r).w = (a).w; }
  53. #define CROSS(r,a,b)      { (r).x = (a).y * (b).z - (a).z * (b).y;\
  54.                             (r).y = (a).z * (b).x - (a).x * (b).z;\
  55.                             (r).z = (a).x * (b).y - (a).y * (b).x; }
  56. #define DOT_PRODUCT(a,b)  ( (a).x * (b).x +\
  57.                             (a).y * (b).y +\
  58.                             (a).z * (b).z )
  59. #define SET_COORD(r,a,b,c) { (r).x = (a); (r).y = (b); (r).z = (c); }
  60. #define SET_COORD4(r,a,b,c,d) { (r).x = (a); (r).y = (b); (r).z = (c);\
  61.                                  (r).w = (d); }
  62. #define SUB2_COORD(r,a)         { (r).x -= (a).x; (r).y -= (a).y;\
  63.                                 (r).z -= (a).z; }
  64. #define SUB3_COORD(r,a,b)    { (r).x = (a).x - (b).x;\
  65.                                  (r).y = (a).y - (b).y;\
  66.                                  (r).z = (a).z - (b).z; }
  67.